import { useAuthStore } from '@/stores';
export const isLogin = (redirectToLoginPage = false) => {
	const authStore = useAuthStore();
	const _is = !!(authStore.profile && authStore.profile.access_token);
	if (!_is && redirectToLoginPage) {
		uni.showToast({
			icon: 'none',
			title: '未登录，请先登录！'
		});
		setTimeout(() => {
			uni.navigateTo({
				url: '/pages/login/login'
			});
		}, 1500);
	}
	return _is;
}

export const getWxUserId = () => {
	const authStore = useAuthStore() as any;
	return authStore?.profile?.userId;
}

export const getWxOpenId = () => {
	const authStore = useAuthStore() as any;
	return authStore?.profile?.openId;
}

export const getLawFirmId = () => {
	const authStore = useAuthStore() as any;
	return authStore?.law?.lawFirmId;
}

// 律所类型（1=律师，2=律所）
export const getLawFirmType = () => {
	const authStore = useAuthStore() as any;
	return authStore?.law?.lawFirmType;
}

export const isLawyer = () => {
	return getLawFirmType() == '1'
}
